home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / go / prog / nextgo23.taz / nextgo23 / NeXTGo / openregn.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-02-09  |  672 b   |  42 lines

  1. #include "comment.header"
  2.  
  3. #define EMPTY 0
  4.  
  5. extern unsigned char p[19][19];
  6.  
  7. int openregion(int i1, int j1, int i2, int j2)
  8.      /* check if region from i1, j1 to i2, j2 is open */
  9. {
  10.   int minx, maxx, miny, maxy, x, y;
  11.   
  12.   /* exchange upper and lower limits */
  13.   
  14.   if (i1 < i2)
  15.     {
  16.       miny = i1;
  17.       maxy = i2;
  18.     }
  19.   else
  20.     {
  21.       miny = i2;
  22.       maxy = i1;
  23.     }
  24.   
  25.   if (j1 < j2)
  26.     {
  27.       minx = j1;
  28.       maxx = j2;
  29.     }
  30.   else
  31.     {
  32.       minx = j2;
  33.       maxx = j1;
  34.     }
  35.   
  36.   /* check for empty region */
  37.   for (y = miny; y <= maxy; y++)
  38.     for (x = minx; x <= maxx; x++)
  39.       if (p[y][x] != EMPTY) return 0;
  40.   return 1;
  41. }  /* end openregion */
  42.